<script src="<?php echo $this->basePath('js/plugins/clipboard/clipboard.min.js')?>"></script>
<div class="content-wrapper">

    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>
        <h1 class="pull-right">
            <a href="<?php echo $this->url('goods-other-tag', ['action'=> 'add']);?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> <?php echo $this->translate('添加聚合标签'); ?></a>
            <?php echo $this->HelpUrl('goodsOtherTag'); ?>
        </h1>
    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                <div class="box shop-box">
                    <div class="box-body table-responsive no-padding">
                        <table class="table shop-table table-hover">
                            <thead>
                            <tr class="shop-bg-thead">
                                <th style="width: 30%"><?php echo $this->translate('标签名称'); ?></th>
                                <th style="width: 30%"><?php echo $this->translate('标签标题'); ?></th>
                                <th style="width: 8%"><?php echo $this->translate('状态'); ?></th>
                                <th style="width: 8%"><?php echo $this->translate('商品数量'); ?></th>
                                <th style="width: 24%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            </thead>
                                <tbody>
                                <?php if($this->otherTagList) foreach ($this->otherTagList as $value) { ?>
                                    <tr>
                                        <td><?php echo $this->escapeHtml($value[0]->getOtherTagName()); ?></td>
                                        <td><?php echo $this->escapeHtml($value[0]->getOtherTagTitle()); ?></td>
                                        <td><?php echo $this->goodsHelper()->otherTagState($value[0]->getOtherTagState()); ?></td>
                                        <td><?php echo $value['goodsNum']; ?></td>
                                        <td>
                                            <a href="<?php echo $this->url('goods-other-tag', ['action'=>'edit', 'id'=>$value[0]->getOtherTagId()]); ?>" class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('编辑'); ?></a>
                                            <a href="<?php echo $this->url('goods-other-tag', ['action'=>'editTagGoods', 'id'=>$value[0]->getOtherTagId()]); ?>" class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('设置商品'); ?></a>

                                            <input type="hidden" name="otherTagUrl<?php echo $value[0]->getOtherTagId(); ?>" id="otherTagUrl<?php echo $value[0]->getOtherTagId(); ?>" value="<?php echo $this->url('shop-other', ['action'=>'tagGoods', 'id' => $value[0]->getOtherTagId()], ['force_canonical' => true]); ?>">
                                            <button type="button" id="btn-copy-otherTagUrl<?php echo $value[0]->getOtherTagId(); ?>" onclick="copyOtherTagUrl(<?php echo $value[0]->getOtherTagId(); ?>);" class="btn btn-xs btn-primary"><i class="fa fa-files-o" aria-hidden="true"></i> <?php echo $this->translate('复制前台链接'); ?></button>

                                            <a href="javascript:;" onclick="deleteConfirm('<?php echo $this->translate('您确实要删除该聚合标签吗?'); ?>', '<?php echo $this->url('goods-other-tag', ['action'=>'delete', 'id'=>$value[0]->getOtherTagId()], ['query' => ['qToken' => $this->adminHelper()->getCsrfValue()]]); ?>');" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i> <?php echo $this->translate('删除'); ?></a>
                                        </td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

    </section>
</div>
<script type="text/javascript">
    function copyOtherTagUrl(otherTagId) {
        let clipboard = new ClipboardJS('#btn-copy-otherTagUrl'+otherTagId, { text: function() { return $('#otherTagUrl'+otherTagId).val() }});
        clipboard.on('success', function (e) {
            layer.msg('复制完成！');
            clipboard.destroy();
        });
        clipboard.on('error', function (e) {
            layer.msg('复制不成功，请您手动进行复制！');
        });
    }
</script>